📍 Toronto, ON

Oliver Kwun-Morfitt

CS @ University of Toronto

Interested in:

Quantitative trading
Machine Learning & AI
Math & Statistics
Software Engineering
/posts/Evolution%20Simulated%20with%20Neural%20Networks

Evolution Simulated with Neural Networks

I created a little simulation of natural selection with PyGame and AI.

2024-08-09T19:07:23+00:00

A little while ago, I created a simple evolution simulation. You can view the code here: my code.

While this is a very simple algorithm, it was incredibly rewarding to simulate a simplified version of Natural Selection. At the time, I was very interested in how organisms evolve, this lead me to realizing “I can just simulate it… kinda”.

So I set out to create a simulation. This was my first time using PyGame, as a result, the visualization could be improved. It is also slow, I should have optimized this network to perform better with the help PyTorch and CUDA, but at the time I had no idea how to.

This project helped me build more intuition on how to incentivize a neural network and how funny they can behave. An example of this was adding obstacles. I wanted the algorithm to learn how to navigate through it, but poorly placed obstacles actually resulted in worse performance, where the algorithm would find it most optimal to just fully avoid them. This is where reward tuning would have made a big difference.

All in all, this was a really awesome project to work as a newbie to ML/AI.

You can view the video after just 20 geneations. We see how well it can navigate in order to maximize the efficiency of their paths to the ”food”.

view count